import urllib.request

# https://www.baidu.com/s?wd=周杰伦
# url 组成      协议            主机             端口号       路径       参数        锚点
#           http/https    www.baidu.com        80/443      s       wd=苍井空      #
url = 'https://www.baidu.com/'

headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36'
}

# 请求对象定制
request = urllib.request.Request(url=url, headers=headers)

response = urllib.request.urlopen(request)

content = response.read().decode('utf8')

print(content)



